#include <iostream>
#include <algorithm>


using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
int n,m;
LL a[N];

int find(LL x)
{
    int left = 1,right = m;
    while(left < right)
    {
        int mid = (left + right) / 2;
        if(a[mid] >= x)
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }
    return left;
}

int main()
{
    cin >> m >> n;
    for(int i = 1;i <= m;i++)
    {
        cin >> a[i];
    }
    sort(a + 1,a + 1 + m);

    a[0] = -1e7 + 10;

    LL ret = 0;
    for(int i = 1;i <= n;i++)
    {
        LL b;
        cin >> b;
        int pos = find(b);
        ret += min(abs(a[pos] - b),abs(a[pos - 1] - b));
    }
    cout << ret << endl;
    return 0;
}


